<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function success($message, $data = null, $pageSize = null, $statusCode = 200) {
        return response()->json([
            'code' => 1,
            'message' => $message,
            'data' => $data,
            'pageSize' => $pageSize
        ], $statusCode);
    }

    public function error($message, $data = null, $statusCode = 200) {
        return response()->json([
            'code' => 0,
            'message' => $message,
            'data' => $data
        ], $statusCode);
    }

    public function unValidate($message, $statusCode = 200) {
        return response()->json([
            'code' => -1,
            'message' => $message,
            'data' => '验证未通过'
        ], $statusCode);
    }
}
